let serverurl = 'http://localhost:8080';

export default {
    //组合查询带排序的菜品
    complexQuery: `${serverurl}/food/searchByFood`,
    //根据菜品名模糊查询菜品
    blurSearch: `${serverurl}/food/searchfoodbynameandkind`,
    //根据菜品ID查找菜品
    foodDetail:`${serverurl}/food/detail`,
    //根据菜品ID查找对应评论
    foodEvaluation:`${serverurl}/evaluation/show`,
    //获取所有菜品分类
    foodKinds:`${serverurl}/foodkind/all`,
    //根据分类id获得菜品
    foodsKind:`${serverurl}/food/searchfoodbykind`,
    //菜品加入购物车
    foodToCart:`${serverurl}/shoppingcartdetail/add`,
    //减少购物车里的菜品
    foodFromCart:`${serverurl}/shoppingcartdetail/del`,
    //移除购物车的菜品
    foodAwayCart:`${serverurl}/shoppingcartdetail/remove`,
    //修改购物车明细
    foodChangeCart:`${serverurl}/shoppingcartdetail/exchange`,
    //另一种删除购物车明细
    foodexAwayCart:`${serverurl}/shoppingcartdetail/exremove`,
    //获得所有购物车明细
    foodsInCart:`${serverurl}/cart/mycart`,
    //注册用户
    registerUser:`${serverurl}/user/register`,
    //获取订单下的菜品
    foodsInOrder:`${serverurl}/goodorderdetail/getorderdetail`,
    //添加评价
    exAddEvaluation:`${serverurl}/evaluation/exadd`,
    //修改订单状态
    orderStatusChange:`${serverurl}/goodorder/updategoodorder`,
    //退出登录
    logout:`${serverurl}/user/logout`,
    //精确四则运算
    mul:function(arg1, arg2) {
        let m = 0,
            s1 = arg1.toString(),
            s2 = arg2.toString();
        try {
            m += s1.split(".")[1].length
        } catch (e) {}
        try {
            m += s2.split(".")[1].length
        } catch (e) {}
        return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
    },
    add:function(arg1, arg2) {
        let r1, r2, m;
        try {
            r1 = arg1.toString().split(".")[1].length
        } catch (e) {
            r1 = 0
        }
        try {
            r2 = arg2.toString().split(".")[1].length
        } catch (e) {
            r2 = 0
        }
        m = Math.pow(10, Math.max(r1, r2))
        return (arg1 * m + arg2 * m) / m
    },
    sub:function(arg1, arg2) {
        let r1, r2, m, n;
        try {
            r1 = arg1.toString().split(".")[1].length
        } catch (e) {
            r1 = 0
        }
        try {
            r2 = arg2.toString().split(".")[1].length
        } catch (e) {
            r2 = 0
        }
        m = Math.pow(10, Math.max(r1, r2));
        n = (r1 >= r2) ? r1 : r2;
        return ((arg1 * m - arg2 * m) / m).toFixed(n);
    },
    // div:function(arg1, arg2) {
    //     let t1 = 0,
    //         t2 = 0,
    //         r1, r2;
    //     try {
    //         t1 = arg1.toString().split(".")[1].length
    //     } catch (e) {}
    //     try {
    //         t2 = arg2.toString().split(".")[1].length
    //     } catch (e) {}
    //     with(Math) {
    //         r1 = Number(arg1.toString().replace(".", ""))
    //         r2 = Number(arg2.toString().replace(".", ""))
    //         return accMul((r1 / r2), pow(10, t2 - t1));
    //     }
    // },
}